<!--组件-信号设置-->
<template>
  <div>

    <!--标题-->
    <div class="title all">
      <text class="font28 text2">{{T('开仓信号')}}</text>
    </div>

    <div class="frame bg2" @click="selectClick">

      <template v-if="param.openSignalMap">
        <LImage v-if="param.openSignalMap.signalType=='priceWarn'" 
        class="img-logo" :src="Config.img('zidingyi.png')" />
        <LImage v-else class="img-logo" :src="Config.img('jiagejingbao.png')" />

          <template v-if="param.openSignalEdit">
          <text class="font28 text1 all">{{param.openSignalMap.signalName}}</text>
          <LImage class="arrow-right-image" :src="Config.img('youjin.png')"></LImage>
        </template>
        <template v-else>
          <text class="font28 text2 all">{{param.openSignalMap.signalName}}</text>
          <LImage class="arrow-right-image" :src="Config.img('youjin.png')"></LImage>
        </template>
      </template>

      <template v-else>
        <text class="font28 text2 all">{{T('请选择信号')}}</text>
        <LImage class="arrow-right-image" :src="Config.img('youjin.png')"></LImage>
      </template>
    </div>
  </div>
</template>

<script>


//功能
const weexFunction = weex.requireModule('WeexFunction');


import modal from "@/_js/modal";
import navigator from "@/_js/navigator"; 
import Config from "@/_js/config";
import broadcast from "@/_js/broadcast";

import I18N from "@/_i18n/i18n";
var T = I18N.t;

var normParam = { 
  'openSignalMap':false, //开仓信号
  'openSignalEdit':true, //true 可编辑
}

//组件
import VInput from "@/public/view/VInput.vue";
export default {

  components: {
    VInput,
  },

  model:{
    prop:"param",
    event:"change",
  },
  
  props:{
    param:Object,
  },

  watch: {
    param: {
      deep: false,
      handler (val, oldVal) {
        this.initParam(val);
      }
    }
  },
  
  data() {
    return {
      T:T,
      Config:Config,
    };
  },

  mounted(){

    this.initParam(this.param);
  },

  methods:{


    //初始化参数
    initParam(param){

      if (!param || param == undefined || JSON.stringify(param) == '{}') {
        this.param = JSON.parse(JSON.stringify(normParam));
        weexFunction.debugLog(this.param)
        this.$emit("change", this.param); 
      }
    },

    /********************************** 点击触发*/
    //选着点击
    selectClick() {
      var param = {};
      navigator.open('', 'up/SelectSignal', param);
      broadcast.subscribeOnce('SelectSignal', (signal)=>{
        this.param['openSignalMap'] = signal;
        this.param['id'] = signal.signalId;
      });
    }
  }
}
</script>


<style src="@/_css/style.css"></style>
<style scoped>
.title{
  flex-direction: row;
  align-items: center;
  margin-bottom: 20px;
}
.explain {
  width: 28px;
  height: 28px;
  margin-left: 8px;
  margin-right: 8px;
}

.arrow-right-image {
  width: 20px;
  height: 20px;
}

.frame{
  flex-direction: row;
  align-items: center;

  height: 88px;
  border-radius: 16px;

  border-width: 2px;
  border-color: transparent;

  padding-left: 20px;
  padding-right: 20px;

  margin-top: 20px;
}
.img-logo {
  width: 50px;
  height: 50px;
  margin-right: 10px;
}
</style>
